Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache access tokens client side #3565

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

woutslakhorst
Copy link
Member

@woutslakhorst woutslakhorst commented Nov 18, 2024

Cache access tokens per request. Subsequent requests are fulfilled from cache.
Added SessionOption to allow for custom ttl on session store.
Only implemented for auth.iam, not for auth/v1

closes #3552

@woutslakhorst woutslakhorst force-pushed the feature/3552/cached_access_tokens branch from a262394 to ea54414 Compare November 18, 2024 11:08
@woutslakhorst woutslakhorst force-pushed the feature/3552/cached_access_tokens branch from ea54414 to 0e660b0 Compare November 22, 2024 08:44
@woutslakhorst woutslakhorst marked this pull request as ready for review November 22, 2024 08:56
Copy link
Member

@reinkrul reinkrul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small remarks/questions

if err != nil {
// this can be an internal server error, a 400 oauth error or a 412 precondition failed if the wallet does not contain the required credentials
return nil, err
}
ttl := accessTokenValidity
if tokenResult.ExpiresIn != nil {
ttl = time.Second * time.Duration(*tokenResult.ExpiresIn)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when could it not be set 🤔 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pointer, probably because the spec says it's optional. In our implementation it's not but you never know.

}
// TTL can't go below 0 because that is translated to "no expiration" by the library
// in that case it should be 1 nanosecond
if opts.ttl < 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just not put it in cache?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦

@woutslakhorst woutslakhorst merged commit 0fa8fb5 into master Nov 22, 2024
9 checks passed
@woutslakhorst woutslakhorst deleted the feature/3552/cached_access_tokens branch November 22, 2024 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache access tokens
2 participants